<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:sec="http://www.springframework.org/security/facelets/tags"
                xmlns:c="http://java.sun.com/jstl/core" 
				template="/WEB-INF/layouts/template.xhtml">

<ui:define name="main">
<script type="text/javascript">document.getElementById('menuProjects').className="selected";</script>
<div id="main">
	<div id="wrapper" class="yui-b">
		<h3 class="title">
			<h:outputText value="${msg.title_project_edit} ${project.name}" rendered="${!(project.id eq 0)}"/>
			<h:outputText value="${msg.title_project_add}" rendered="${project.id eq 0}"/>
		</h3>
		<ui:fragment id="messages">
			<div id="messagesInsertionPoint">
				<h:messages errorClass="errors" />
			</div>
		</ui:fragment>
		<div class="wrapper">
			<h:form id="project">		
				<div class="field">
					<div class="label">
						<h:outputLabel for="name">${msg.name} </h:outputLabel>
					</div>
					<div class="input">
						<h:inputText id="name" value="${project.name}"/>
					</div>
				</div>
				<div class="field">
					<div class="label">
						<h:outputLabel for="description">${msg.description} </h:outputLabel>
					</div>
					<div class="input">
						<h:inputText id="description" value="${project.description}"/>
					</div>
				</div>
				<div class="field">
					<div class="label">
						<h:outputLabel for="hours">${msg.hours} </h:outputLabel>
					</div>
					<div class="input">
						<h:inputText id="hours" value="${project.hours}"/>
					</div>
				</div>
				<div class="field">
					<div class="label">
						<h:outputLabel for="client">${msg.client} </h:outputLabel>
					</div>
					<div class="input">
						<h:selectOneMenu id="client" value="${project.client}">
							<f:selectItem itemValue="${null}" itemLabel="${null}"/>
							<c:forEach items="${viewScope.clients}" var="client">
								<f:selectItem itemValue="${client}" itemLabel="${client.name}"/>
								<f:converter converterId="clientConverter"/>
							</c:forEach>
						</h:selectOneMenu>
					</div>
				</div>
				<div class="field">
					<div class="label">
						<h:outputLabel for="members">${msg.assignedMembers} </h:outputLabel>
					</div>
					<div class="input">
						<h:selectManyCheckbox value="${project.assignedMembers}" layout="pageDirection">
							<c:forEach items="${viewScope.members}" var="member">
								<f:selectItem itemValue="${member}" itemLabel="${member.contact.name}"/>
								<f:converter converterId="memberConverter"/>
							</c:forEach>
						</h:selectManyCheckbox>
					</div>
				</div>
				<div class="field">
					<div class="label">
						<h:outputLabel for="retired">${msg.retired} </h:outputLabel>
					</div>
					<div class="input">
						<h:selectBooleanCheckbox id="retired" value="${project.retired}" />
					</div>
				</div>
				<div>
					<sf:commandLink id="save" action="save" processIds="*" rendered="${!(project.id eq 0)}"><div class="button">${msg.save}</div></sf:commandLink>
					<sf:commandLink id="create" action="create" processIds="*" rendered="${project.id eq 0}"><div class="button">${msg.create} ${msg.project}</div></sf:commandLink>
				</div>
			</h:form>
		</div>
	</div>
</div>
<div style="clear: both; height: 5px;" />
<div>
	<h:form>
		<sf:commandLink id="back" action="back"  rendered="${!(project.id eq 0)}"><div class="button">${msg.back} ${msg.project}</div></sf:commandLink>
		<sf:commandLink id="cancel"  action="cancel" rendered="${project.id eq 0}"><div class="button">${msg.cancel}</div></sf:commandLink>
	</h:form>
</div>
</ui:define>
</ui:composition>